import { ElMessage } from "element-plus"
import router from "./router"
import { useUserStore } from "./stores/user"
const WHITE_LIST = ['/login','404']
import { useRoute } from "vue-router" 
router.beforeEach((to,from,next)=>{
  const route=useRoute()
  console.log(route.path);
  const store=useUserStore()
  if(store.token){
    next()
  }else{
    if(WHITE_LIST.includes(to.path)){
      next()
    }else{
      next('/login')
      ElMessage.error('登录信息失效，请先登录')
    }
  }
})